#!/usr/bin/env python
from google.appengine.api import users
import simplejson as json
import string
import webapp2


class Login(webapp2.RequestHandler):
    def get(self):
        if users.get_current_user():
            url = users.create_logout_url(string.replace(self.request.path,'/login/','/mensajes/?codmsj=2'))
            url_linktext = 'Logout'
        else:
            url = users.create_login_url(string.replace(self.request.path,'/login/','/mensajes/?codmsj=1'))
            url_linktext = 'Login'
        
        self.response.out.write(json.dumps({ "url": url, "url_linktext": url_linktext }))